{extend name="public/father" /}

{block name='main'}
<div class="layui-card">
    <div class="layui-card-header">用户列表</div>
    <div class="layui-card-body">

        <div class="layui-btn-container">
            <button class="layui-btn" onclick="openUrl('添加', 'create', 480,420);return false;"><i class="layui-icon layui-icon-addition"></i>添加用户</button>
        </div>

        <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>

        <script type="text/html" id="status">
            <input type="checkbox" name="status" lay-skin="switch" lay-text="已启用|已禁用" data-href="{:url('status')}?t=users&id={{ d.id }}" lay-filter="switchStatus" value="{{ d.status }}" {{ d.status==1 ? 'checked' : '' }}>
        </script>

        <script type="text/html" id="barDemo">
            <div class="layui-btn-group">
                <a class="layui-btn layui-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>修改</a>
                <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del" data-table="users"><i class="layui-icon layui-icon-delete"></i>删除</a>
	            <a class="layui-btn layui-btn-sm" lay-event="xufei"><i class="layui-icon layui-icon-rmb"></i>续费</a>
            </div>
        </script>

        <script type="text/html" id="admin">
        {{ d.admin == 1 ? '管理员' : '' }}
        {{ d.admin == 2 ? 'VIP用户' : '' }}
        {{ d.admin == 3 ? '代理' : '' }}
        {{ d.admin == 4 ? '视频管理' : '' }}
        </script>

    </div>
</div>
{/block}


{block name="js"}
<script type="text/javascript">
    layui.use(['table', 'form'], function() {
        let $ = layui.jquery, table = layui.table, form = layui.form;

        table.render({
            elem: '#dataTable',
            url: "{:url()}?so={:trim(input('param.so'))}",
            title: '数据表',
            cellMinWidth: 200,
            limit: 20,
            size: 'lg',
            cols: [[
                {field: 'left',		title:'操作',	width:220,	align:'center',	toolbar:'#barDemo'},
                {field: 'status',	title:'状态',	width:110,	align:'center',	sort:true,	templet:'#status'},
                {field: 'username',	title:'用户名',	minWidth:200,	align:'center',	sort:true},
	            {field: 'admin',	title:'权限',	width:100,	align:'center',	sort:true,		templet:'#admin'},
	            {field: 'end_time',	title:'到期时间',		width:170,templet: "<div>{{layui.util.toDateString(d.end_time*1000, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
            ]],
            page: true
        });

    });

</script>
{/block}
